package com.example.knowledge.mvvm.adapter
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.example.knowledge.R
import com.example.knowledge.mvvm.activity.ReportDetailActivity
import com.example.knowledge.mvvm.bean.RecordsBean
import com.gsafety.libraryktx.config.Constant

/**
 * @author : lj
 * @date : 2021/1/6 15:44
 */
class ReportListAdapter(data: List<RecordsBean>?) :
    BaseQuickAdapter<RecordsBean, BaseViewHolder>(
        R.layout.know_report_items_view, data
    ) {
    override fun convert(helper: BaseViewHolder?, item: RecordsBean) {
        helper?.let {
            it.itemView.setOnClickListener{
                ReportDetailActivity.startIntent(mContext,item.id,item.reportName)
            }
            when(item.reportTypeCode){
                Constant.CODE_REPORT_MONTH->{
                    it.setImageResource(R.id.iv_left_icon, R.mipmap.know_icon_month)
                }
                Constant.CODE_REPORT_JI->{
                    it.setImageResource(R.id.iv_left_icon, R.mipmap.know_icon_jidu)
                }
                Constant.CODE_REPORT_YEAR->{
                    it.setImageResource(R.id.iv_left_icon, R.mipmap.know_icon_year)
                }
            }
            it.setText(R.id.tv_item_title, item.reportName)
            it.setText(R.id.tv_item_title_desc, item.reportdesc)
            it.setText(R.id.tv_item_time_desc, item.sdefCreateDate)

        }
    }


}